home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / ArchiveUtils / JumpBack / Source / pathutil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  798 b   |  46 lines

  1. /* this is a bogus .c file to cover for the disapearence of the text lib */
  2.  
  3. #import    <c.h>            /* TRUE/FALSE */
  4. #import <strings.h>
  5. #import <sys/param.h>        /* MAXPATHLEN */
  6. #import <sys/types.h>
  7. #import <sys/stat.h>
  8.  
  9. extern char *basename(s)
  10. char *s;
  11. {    char *ptr;
  12.     ptr = rindex(s,'/');
  13.     if (!ptr) ptr = s;
  14.     else ptr++;        /* walk past the slash */
  15.     return ptr;
  16. }
  17.  
  18. extern char *parentname(s)
  19. char *s;
  20. {
  21.     char    *ptr;
  22.     static char buf[MAXPATHLEN+1];
  23.     strcpy(buf,s);
  24.     ptr = rindex(buf,'/');
  25.     if (ptr) {
  26.         if (ptr == buf)
  27.             ptr[1]='\0';
  28.         else    *ptr = '\0';
  29.     } else buf[0] = '\0';
  30.     return buf;
  31. }
  32.  
  33. extern int isDirectory(s)
  34. char *s;
  35. {
  36.     struct stat buf;
  37.     int flag;
  38.     if (stat(s,&buf) == 0){
  39.         if ((buf.st_mode &  S_IFDIR) ==  S_IFDIR) 
  40.             flag = TRUE;
  41.         else    flag = FALSE;
  42.     } else flag = FALSE;
  43.     return flag;
  44. }
  45.  
  46.